﻿namespace QLPhongKham.Access.VienPhi
{
    using ConfigDatabase.Class;
    using Npgsql;
    using QLPhongKham.Access;
    using QLPhongKham.BaseClass.Chung;
    using System;

    public class VPThongSo
    {
        private ConnectDatabase _condata;
        private NpgsqlConnection _conn;
        private dtoDSThongSo _dtots;
        private int _idthongso;
        private General _xuli;

        public VPThongSo()
        {
            this._idthongso = 0x11;
            this._condata = new ConnectDatabase();
            this._dtots = new dtoDSThongSo(this._condata);
            this._xuli = new General(this._condata);
        }

        public VPThongSo(ConnectDatabase condata)
        {
            this._idthongso = 0x11;
            this._condata = condata;
            this._dtots = new dtoDSThongSo(this._condata);
            this._xuli = new General(this._condata);
        }

        private string f_GetThongSo(int stt, string ten, string giatri1, string giatri2)
        {
            this._dtots.ID = this._idthongso;
            this._dtots.STT = stt;
            this._dtots.TEN = ten;
            this._dtots.GIATRI2 = giatri2;
            this._dtots.GIATRI1 = giatri1;
            this._dtots.Load();
            try
            {
                return this._dtots.GIATRI1;
            }
            catch
            {
                return "";
            }
        }

        private void f_SetThongSo(int stt, string ten, string giatri1, string giatri2)
        {
            this._dtots.ID = this._idthongso;
            this._dtots.STT = stt;
            this._dtots.TEN = ten;
            this._dtots.GIATRI1 = giatri1;
            this._dtots.GIATRI2 = giatri2;
            if (!this._dtots.Update())
            {
                this._dtots.Insert();
            }
        }

        public bool pVP_A1_QuanLyQuyenSo
        {
            get
            {
                try
                {
                    return (this.f_GetThongSo(enSTT.vp_chonquyenso.GetHashCode(), enSTT.vp_chonquyenso.ToString(), "", "") == "1");
                }
                catch
                {
                    return false;
                }
            }
            set
            {
                this.f_SetThongSo(enSTT.vp_chonquyenso.GetHashCode(), enSTT.vp_chonquyenso.ToString(), value ? "1" : "0", "");
            }
        }

        private enum enSTT
        {
            vp_chonquyenso = 1
        }
    }
}

